package com.xdxc.controller;


import com.xdxc.exception.CustomException;
import com.xdxc.feign.QuestionFeign;
import com.xdxc.response.Result;
import com.xdxc.vo.QuestionWithOptionsVo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;
@RestController
@RequestMapping(value = "/question/index")
public class QuestionController {

    @Autowired
   private    QuestionFeign questionFeign;

    @GetMapping()
    public Result getQuestionList(
            @RequestParam(defaultValue = "1") int page, // 页码，默认为1
            @RequestParam(defaultValue = "5") int size  // 每页条数，默认为5
    ){
        Result<QuestionWithOptionsVo>  questionWithOptionsVoResult= questionFeign.batchQuestionPage(page,size);
        if(questionWithOptionsVoResult.getCode()==1){
            return questionWithOptionsVoResult;
        }else {
           throw new CustomException(500,"服务内部异常");

        }
    }
}
